 // 剑指offer22
    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }

    public ListNode getKthFromEnd(ListNode head, int k) {
        int len=0;
        ListNode temp=head;
        while(temp.next!=null){
            len++;
            temp=temp.next;
        }

        int s=len+1-k;

        for(int i=1;i<=s;i++){
            head=head.next;
        }
        return head;
    }